package com.xysd.express.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.widget.CheckedTextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xysd.express.R;
import com.xysd.express.bean.CargoTypeObj;

/**
 * Created by donghui on 2017/11/20.
 */

public class CargoTypeAdpter extends BaseQuickAdapter<CargoTypeObj.CargoType,BaseViewHolder> {
    Context context;
    int curItem;

    public CargoTypeAdpter(@LayoutRes int layoutResId, Context context) {
        super(layoutResId);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, CargoTypeObj.CargoType item) {
        CheckedTextView type_tv=helper.getView(R.id.type_tv);
        helper.setText(R.id.type_tv,item.Name);

        if (curItem != -1) {
            if (curItem == helper.getAdapterPosition()) {
                type_tv.setChecked(true);
            } else {
                type_tv.setChecked(false);
            }
        }
    }

    //设置选中的哪一个
    public void setCurSelect(int position) {
        this.curItem = position;
        notifyDataSetChanged();
    }
}
